﻿#region

using System.Windows.Forms;
using DevExpress.XtraEditors;

#endregion

namespace KQReport.Utils
{
    public static class Dialog
    {
        public static void MsgOk(IWin32Window window, string msg)
        {
            XtraMessageBox.Show(window, msg, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }

        public static void MsgError(IWin32Window window, string msg)
        {
            XtraMessageBox.Show(window, msg, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }

        public static bool MsgAsk(IWin32Window windows, string msg)
        {
            var dialogResult = XtraMessageBox.Show(windows, string.Format("您确定要{0}吗？", msg),
                                                   "提示",
                                                   MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk,
                                                   MessageBoxDefaultButton.Button1);
            return (dialogResult == DialogResult.OK || dialogResult == DialogResult.Yes) ? true : false;
        }

        public static bool MsgAskC(IWin32Window windows, string msg, MessageBoxDefaultButton? button = null)
        {
            var dialogResult = XtraMessageBox.Show(windows, msg,
                                                   "提示",
                                                   MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk,
                                                   button ?? MessageBoxDefaultButton.Button1);
            return (dialogResult == DialogResult.OK || dialogResult == DialogResult.Yes) ? true : false;
        }
    }
}